﻿<UserControls:ScrumUserControl x:Class="ScrumTable.UI.View.WinTouch.UserControls.View.StartScreenControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:s="http://schemas.microsoft.com/surface/2008"
    xmlns:loc="clr-namespace:ScrumTable.UI.View.Localization;assembly=ScrumTable.UI.View" xmlns:System="clr-namespace:System;assembly=mscorlib" xmlns:UserControls="clr-namespace:ScrumTable.UI.View.WinTouch.UserControls" xmlns:Converter="clr-namespace:ScrumTable.UI.View.Converter;assembly=ScrumTable.UI.View"
                               xmlns:CustomControl="clr-namespace:ScrumTable.UI.View.WinTouch.CustomControl"
                               x:Name="Root"    
    Foreground="White" Background="White" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
    <UserControls:ScrumUserControl.Resources>
        <Converter:ConverterBitMapToImageSource x:Key="BitmapConvert"/>
        <Converter:ConverterListCountVisibility x:Key="IsEmptyListConverter"/>
        <Converter:ConverterBoolVisibility x:Key="ConverterVisiblity2"/>
        <Converter:ConverterNotBoolVisibility x:Key="ConverterVisiblity"/>
        <Converter:ConverterResolution x:Key="WidthResConverter" BasisValue="400" ResolutionType="Horizontal"/>              
        <Converter:ConverterListCountVisibility x:Key="IsNotEmptyListConverter" Invert="True"/>        
    </UserControls:ScrumUserControl.Resources>

    <Grid>
        <Image Source="{StaticResource BrandedLogo}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="{Binding Converter={StaticResource WidthResConverter}}" Margin="50"/>
        <Image Source="{StaticResource HSRLogo}" HorizontalAlignment="Right" VerticalAlignment="Top" Width="{Binding Converter={StaticResource WidthResConverter}}" Margin="50"/>

        <Rectangle Fill="#FFA4E4F3" HorizontalAlignment="Stretch" VerticalAlignment="Center" Height="186" Margin="0,98,0,51" />
        <Rectangle HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="0,283,0,-12"  Height="64">
            <Rectangle.Fill>
                <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
                    <GradientStop Color="#FFCAF3FC"></GradientStop>
                    <GradientStop Color="#FFEFFCFE" Offset="1"></GradientStop>
                </LinearGradientBrush>
            </Rectangle.Fill>
        </Rectangle>
        <UserControl Background="{StaticResource StartBackground}" HorizontalAlignment="Left" VerticalAlignment="Center" Width="619" Height="335" Margin="-63,-7,0,7" />
        
        <StackPanel  HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="10,0,5,45" >
            <ComboBox BorderThickness="0"  Name="LanguageSelector" BorderBrush="Transparent" Background="Transparent"  Width="200" Height="58" SelectionChanged="OnLanguageChanged" ItemsSource="{x:Static  Member=loc:ScrumTableLanguage.SupportedLanguage}" SelectedValue="{Binding ConfigManager.CultureInfo}"  SelectedValuePath="CultureInfo">
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal" >
                            <Image Source="{Binding ImageSource}" Width="32" Height="32"/>
                            <Label FontSize="12" Margin="5,0,0,0" FontWeight="Normal" VerticalAlignment="Center" Content="{Binding Path=Language}" />
                        </StackPanel>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
            </ComboBox>
        </StackPanel>
 
        
        <TextBlock Margin="629,155,0,258" HorizontalAlignment="Left" Style="{StaticResource DescriptionTextBlock}" Foreground="Black" Visibility="{Binding Path=LoginAccountList.UserList.Count, Mode=OneWay, Converter={StaticResource IsEmptyListConverter}}" Text="{loc:Translate Uid=Welcome_Choose, Default=[ChooseYourProject]}" ></TextBlock>
        

        
        <TextBlock FontSize="36" FontWeight="Bold" Text="{loc:Translate Uid=Welcome_No_User,Default=[Welcome_Activate]}" Panel.ZIndex="1000"   Margin="629,45,50,0" HorizontalAlignment="Left" VerticalAlignment="Center" 
                    Visibility="{Binding Path=LoginAccountList.UserList.Count, Mode=OneWay, Converter={StaticResource IsNotEmptyListConverter}}" 
                    Foreground="Black" />
        
        <Grid HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="619,95,50,0" >                
            <UserControls:SurfaceDragDropListBox  HorizontalAlignment="Left" VerticalAlignment="Center" SelectionChanged="OnUserListSelectionChanged" CanDrag="False"  ScrollViewer.VerticalScrollBarVisibility="Hidden" ScrollViewer.HorizontalScrollBarVisibility="Auto"                                                                                                 
            HorizontalContentAlignment="Left"                                                  
            Opacity="0.75" x:Name="UserList"
            Background="Transparent"
            MultipleColumnsRows="False"            
            AllowDrop="False"         
            BorderThickness="0"
            BorderBrush="LightGray"
            ItemsSource="{Binding Path=LoginAccountList.UserList, Mode=OneWay}"                                          
            IsItemSelectable="True"
            ItemsAreStatic="True"
            Orientation="Horizontal" Margin="-5,0,0,0" >
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel IsItemsHost="True" Orientation="Horizontal"  HorizontalAlignment="Center" Margin="0,0,10,0"/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <UserControls:SurfaceDragDropListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid VerticalAlignment="Top" MaxWidth="150" Width="150" Margin="10,10,0,10">
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <Border BorderBrush="#49FFFFFF" BorderThickness="2,2,0,0"  CornerRadius="2"/>
                            <Border BorderBrush="#49AAAAAA" BorderThickness="0,0,2,2"  CornerRadius="2"/>

                            <Border CornerRadius="2" Margin="2" Background="{StaticResource GrayBrush}">
                                <Grid>
                                    <Image Source="{Binding DataConnectionIcon, Converter={StaticResource BitmapConvert}}" HorizontalAlignment="Right" Width="40" Height="40" Margin="5,30,10,10" Opacity="0.15"/>
                                    <StackPanel HorizontalAlignment="Stretch"  Margin="5" >
                                        <TextBlock Text="{Binding ServerLoginName}"/>
                                        <TextBlock Text="{Binding ProjectId}"/>
                                        <TextBlock Text="{Binding IterationId}"/>
                                    </StackPanel>
                                </Grid>
                            </Border>
                            <s:SurfacePasswordBox Grid.Row="1" KeyboardLayout="Numeric"  HorizontalAlignment="Center" Width="150" Height="0" PreviewKeyDown="OnPasswordBoxPreviewKeyDown">
                                <s:SurfacePasswordBox.Style>
                                    <Style TargetType="{x:Type s:SurfacePasswordBox}" BasedOn="{StaticResource {x:Type s:SurfacePasswordBox}}">
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={ RelativeSource Mode=FindAncestor, AncestorType={x:Type s:SurfaceListBoxItem}}}" Value="true">
                                                <Setter Property="s:SurfacePasswordBox.Height" Value="30"/>
                                                <Setter Property="s:SurfacePasswordBox.MinHeight" Value="30"/>
                                            </DataTrigger>
                                            <DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={ RelativeSource Mode=FindAncestor, AncestorType={x:Type s:SurfaceListBoxItem}}}" Value="false">
                                                <Setter Property="s:SurfacePasswordBox.Height" Value="0"/>
                                                <Setter Property="s:SurfacePasswordBox.MinHeight" Value="0"/>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </s:SurfacePasswordBox.Style>
                            </s:SurfacePasswordBox>
                        </Grid>
                    </DataTemplate>
                </UserControls:SurfaceDragDropListBox.ItemTemplate>
            </UserControls:SurfaceDragDropListBox>
        </Grid>

        <TextBlock Grid.Row="2" FontSize="12" FontWeight="Bold" Foreground="Red" Text="{Binding Path=ErrorConnect}" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="629,400,0,0"/>

        <WrapPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="629,292,0,0" VerticalAlignment="Center">
            <s:SurfaceButton Visibility="Visible" Height="40" Command="{Binding LoginCommand,ElementName=Root}" loc:Translate.Uid="Welcome_Login" Content="{loc:Translate Default=[Login]}" Width="150" Background="{StaticResource GrayBrush}" Margin="0,0,10,0" Style="{StaticResource SurfaceButtonStyle}"/>
            <s:SurfaceButton Visibility="Visible" Height="40" Click="OnRegButtonClick"  loc:Translate.Uid="Welcome_Register" Content="{loc:Translate Default=[Reg]}" Width="150" Background="{StaticResource GrayBrush}" Margin="0,0,10,0" Style="{StaticResource SurfaceButtonStyle}"/>
            <s:SurfaceButton Visibility="Visible" Height="40" Command="{Binding ChangeCommand,ElementName=Root}"  loc:Translate.Uid="Welcome_Change" Content="{loc:Translate Default=[Change]}" Width="150" Background="{StaticResource GrayBrush}" Margin="0,0,10,0" Style="{StaticResource SurfaceButtonStyle}"/>
            <s:SurfaceButton Visibility="Visible" Height="40" Click="OnExitButtonClicked"  loc:Translate.Uid="Welcome_Quit" Content="{loc:Translate Default=[Exit]}" Width="150" Background="{StaticResource GrayBrush}" Margin="0,0,10,0" Style="{StaticResource SurfaceButtonStyle}"/>
        </WrapPanel>


        <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="10,0,0,0">
            <Label Content="{Binding AssemblyInfo}"/>
            <Label Content="{Binding AssemblyDescription}" Foreground="Red"/>
        </StackPanel>

        <s:SurfaceButton  Click="OnDeactiveFlicks" Visibility="{Binding Path=IsFlickEnabled, Converter={StaticResource  ConverterVisiblity2}}" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="10,0,5,120" Style="{x:Null}">
            <StackPanel Orientation="Horizontal" >
                <Label Background="{StaticResource IconWarningSmall}" Width="32" Height="32"/>
                <TextBlock Margin="7,0,0,0" FontSize="12" xml:space="preserve" Text="{loc:Translate Uid=Welcome_FlickWarning, Default=[FlicksAreActiveDisableIt]}"/>
            </StackPanel>
        </s:SurfaceButton> 
        
        <Grid HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="200" Height="43" Margin="5,5,5,5">
            <s:SurfaceButton Background="{StaticResource Keyboard}" Command="{Binding ChangeKeyBoardSetting}"/>                            
            <UserControl IsHitTestVisible="False" HorizontalAlignment="Center" VerticalAlignment="Center" Width="40"  Height="40" Background="{StaticResource IconForbidden}" Visibility="{Binding Path=OnboardKeyboardEnabled, Converter={StaticResource  ConverterVisiblity}}">
            </UserControl>
        </Grid> 
    </Grid>

</UserControls:ScrumUserControl>
